# @Time    :2025/3/28 16:51
"""
求一个整数n的阶乘
"""
# 写一个5的阶乘

# res = 1
# for i in range(1, 6):
#     res *= i  # res=res*i
#
# print(res)

"""
# 写一个5的阶乘 函数实现
def f(n):
    res=1
    for i in range(1,n+1):
        res*=i
    return  res


print((f(5)))
"""
#递归实现阶乘

def f(n):
    if n == 1:
        return 1
    return n * f(n - 1)


print(f(5))